﻿<?php

/**
 * This is the model class for table "article_list".
 *
 * The followings are the available columns in table 'article_list':
 * @property integer $article_id
 * @property string $article_title
 * @property string $article_brief
 * @property string $article_image_url
 * @property string $article_content
 * @property integer $article_sort_id
 * @property string $article_createtime
 * @property integer $browse_number
 * @property integer $comment_number
 */
class ArticleList extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return ArticleList the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'article_list';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('article_sort_id, browse_number, comment_number', 'numerical', 'integerOnly'=>true),
			array('article_title, article_image_url', 'length', 'max'=>255),
			array('article_brief, article_content, article_createtime', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('article_id, article_title, article_brief, article_image_url, article_content, article_sort_id, article_createtime, browse_number, comment_number', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'sortName'=>array(self::BELONGS_TO, 'ArticleSort', 'article_sort_id'), 
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'article_id' => 'Article',
			'article_title' => 'Article Title',
			'article_brief' => 'Article Brief',
			'article_image_url' => 'Article Image Url',
			'article_content' => 'Article Content',
			'article_sort_id' => 'Article Sort',
			'article_createtime' => 'Article Createtime',
			'browse_number' => 'Browse Number',
			'comment_number' => 'Comment Number',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('article_id',$this->article_id);
		$criteria->compare('article_title',$this->article_title,true);
		$criteria->compare('article_brief',$this->article_brief,true);
		$criteria->compare('article_image_url',$this->article_image_url,true);
		$criteria->compare('article_content',$this->article_content,true);
		$criteria->compare('article_sort_id',$this->article_sort_id);
		$criteria->compare('article_createtime',$this->article_createtime,true);
		$criteria->compare('browse_number',$this->browse_number);
		$criteria->compare('comment_number',$this->comment_number);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}